package com.oop.匿名对象;
//3.匿名对象可以当作参数传递
public class ff {
    public static void main(String[] args) {
    /*
        cat c1 = new cat();
        c1.color = "red";
        c1.num = 8;
        c1.run();

        cat c2 = new cat();
        c2.color = "red";
        c2.num = 8;
        c2.run();
    */

    /*  用有名对象
        cat c1 = new cat();
        method(c1);

        cat c2 = new cat();
        method(c2);
     */

     //用匿名对象
     method(new cat());
     method(new cat());

    }
    //抽取方法提高代码的复用性
    public static void method(cat cc){
        cc.color = "red";
        cc.num = 8;
        cc.run();
    }
}

class cat{
    String color;
    int num;
    void run(){
        System.out.println("跑");
    }
}